package com.wjerp.tplus.server.common.constant;

import java.text.MessageFormat;

/**
 * The Enumeration ErrorDetail.
 */
public enum ErrorDetail {
	
	/** The unknow. */
	// **** Warning - Please do not add customized exception code < 1000 **** //
	UNKNOW("-1", "Unknow exception."),
	
	/**  ---- Request Common Error 及非法参数  ----  **/
	REQ_PARAM_BADLY_SET_ERROR("10001", "参数 {0} 未正确设置。"),
	REQ_BADLY_SET_ERROR_GENERAL("10002", "请求参数不正确"),
	INTERNAL_SYSTEM_ERROR("10003", "系统错误"),


	/** ----- 账户管理相关查询结果 ----- **/
	INVALID_PASSWORD_RESET_VCODE("41001", "重置密码验证码失效"),
	INVALID_CHANGE_MOBILE_VCODE("41015", "修改注册手机号验证码失效"),
	INVALID_PASSWORD_RESET_BANK_DETAILS("41002", "重置密码银行信息错误"),
	PLATFORM_USER_EXISTED("41003", "该用户已存在"),
	FAIL_TO_GET_CAPTCHA("41004", "图片验证码生成失败"),
	CAPTCHA_NOT_MATCHED("41005", "图片验证码错误或过期"),
	EMAIL_NOT_FOUND("41006", "邮箱没有注册"),
	INVALID_EMAIL_BIND_TOKEN("41007", "绑定邮箱链接已失效"),
	EMAIL_EXSITING("41014", "邮箱已被使用"),
	PASSWORD_RESET_VCODE_FAIL_TO_SEND("41008", "重置密码手机验证码发送失败"),
	MOBILE_CHANGE_VCODE_FAIL_TO_SEND("41014", "修改注册手机号验证码发送失败"),
	MOBILE_NOT_FOUND("41009", "手机号码未找到"),
	MOBILE_NUMBER_EXSITING("41014", "手机号码已被使用"),
	INVALID_PASSWORD_FORGET_VCODE("41015","忘记密码验证码失败"),
	OLD_MOBILE_EQUAL_NEW_MOBILE("41016","新手机号码和旧手机号码不能相同"),
	DISABLE_USER("41017","用户已冻结，请联系管理员"),
	MODIFY_USER_STATUS_FAIL("41018","账户状态操作失败"),
	CANNOT_FIND_USER("41019", "无法找到用户"),
	USER_EXSITING("41020", "用户已存在"),
	FAIL_CREATE_SYS_USER("41021", "用户创建失败，请重试"),
	FAIL_DISTRIBUTION_PERMISSION_TO_USER("41022", "用户权限分配失败，请重试"),
	FAIL_EDIT_USER("41024", "用户修改失败，请重试"),
	FAIL_RESET_USER_PWD("41023", "用户密码重置失败，请重试"),
	ROLE_EXSITING("41025", "角色名称已存在"),
	ROLE_NOT_EXSITING("41025", "角色名称不存在"),
	FAIL_CREATE_ROLE("41026", "角色操作失败，请重试"),
	FAIL_DISTRIBUTION_PERMISSION_TO_ROLE("41027", "角色权限分配失败，请重试"),
	FAIL_DISTRIBUTION_AGENT_TO_USER("41028", "分配机构失败，请重试"),
	FAIL_DISTRIBUTION_AGENT_BY_HAS_AGENT_TO_USER("41029", "分配机构失败,当前商户已经存在机构，请重试"),



	/**  ---- 上传文件相关结果  ----  **/
	EMPTY_FILE("42001", "上传文件不能为空"),
	ERROR_FILE("42002","文件错误"),
	FAIL_UPLOAD_FILE("42003", "上传文件失败，请重试！"),
	FAIL_DOWNLOAD_FILE("42004", "下载失败，没有相关的数据"),

	/** ----- 店铺相关结果 ----- **/
	STORE_EXSITING("43001","店铺名称已存在"),
	FAIL_CREATE_STORE("43002","新增店铺失败，请重试！"),
	INVALID_PLATFORM_ERROR("43003","非法的电商平台代码"),
	STORE_NOT_FOUND("43004","店铺不存在"),
	STORE_APPROVE("43005","店铺已审核通过，不能进行修改"),
	STORE_EMAIL_IS_NULL("43006","新增店铺失败， 请填写店铺email信息"),
	ACCOUNT_NOT_FUND("43007","收款账号信息不存在"),
	ERROR_WEB_URL("43008","店铺URL错误"),
	ERROR_EMAIL("48009","EMAIL错误"),
	ERROR_RE_SUBMIT_STORE_TO_PSP("43010","操作失败，当前状态不能重新提交店铺信息到账户提供方"),
	ERROR_BIRTH_ORDER_ITEM_BY_STORE_CODE("43011","提交失败，该店铺贸易详情正在获取中"),
	FAIL_STORE_APPROVE_FOR_KYC_STATUS("43012","该商户的实名认证审核尚未通过！"),
	FAIL_CREATE_STORE_IN_EUROPE_ERROR("43013","欧洲不允许创建新店铺！"),
	STORE_INFO_EMPTY("43014","店铺信息为空"),
	EBAY_INIT_PARAMS_INVALID("43015","Ebay初始化参数错误"),


	/** ----- 提现账户相关结果 ----- **/
	WITHDRAW_CARD_EXSITING("44001","提现账户已存在"),
	CURRENCY_ERROR("44002","账户币种不正确"),
	WITHDRAW_ACCOUNT_NOT_FOUND("44003","提现账户不存在"),
	FAIL_TO_DELETE_WITHDRAW_ACCOUNT("44004","提现账户删除失败"),
	FAIL_TO_SETTING_DEFAULT_WITHDRAW_ACCOUNT("44005","设置默认提现账户失败"),
	FAIL_TO_EDIT_WITHDRAW_ACCOUNT("44006","编辑提现账户失败，请重试或联系客服人员"),
    ERRO_BANK_CARD_NUMBER("44007","银行卡号输入有误，请重新输入"),
	ERRO_BANK_CARD_TYPE("44008","不支持该银行卡"),
	DEFAULT_WITHDRAW_ACCOUNT_NOT_FOUND("44009","默认提现账户不存在"),
	FAIL_TO_DELETE_WITHDRAW2_ACCOUNT("44010","审核中的提现账户不能进行删除"),

	/** ----- 商户、账户相关认证状态 ----- **/
	MERCHANT_INFO_NOT_APPROVED("45001", "商户尚未通过认证!"),
	MERCHANT_ACCOUNT_NOT_ACTIVE("45002", "商户没有活动账户!"),
	MERCHANT_ACCOUNT_NOT_FOUND("45003", "找不到商户的账户"),
	FAIL_TO_SUBMIT_VALIDATION_MERCHANT_INFO("40004", "实名认证信息提交失败"),
	KYC_AUDITING("45004", "实名认证信息审核中，不能进行修改"),
	KYC_APPROVE("45005", "实名认证信息已审核通过"),
	FAIL_TO_SUBMIT_VALIDATION_MERCHANT_EDIT_USER_TYPE("45006","实名认证信息提交失败，不能修改实名认证用户类型"),
	MERCHANT_STORE_ACCOUNT_MISMATCHING("45007", "商户、店铺、账号三者不匹配"),
	FAIL_TO_SET_MERCHANT_FEE_BY_SCOPE("45008","设置费率不能低于成本费率"),
	ERROR_RE_SUBMIT_MERCHANT_TO_PSP("45009","操作失败，当前状态不能重新提交商户KYC信息到账户提供方"),
	MERCHANT_FEE_RATE_NOT_SET("45010", "商户未设置费率!"),
	FAIL_TO_FIND_MERCHANT_MANAGE("450011", "该商户没有客户经理"),
	FAIL_TO_FIND_MERCHANT_MANAGE_ERROR("450012", "获取客户经理信息错误"),
	UNKNOW_STATUS_COMMENTS("450013","未知的审核状态"),

	/** ----- 提现操作相关 ----- **/
	AREA_NOT_FOUND("46001", "区域未找到"),
	WITHDRAW_DETAILS_IS_NULL("46002","提现明细不能为空"),
	FAIL_TO_SUBMIT_WITHDRAW("46003","提现失败，请重试"),
	FAIL_TO_SUBMIT_WITHDRAW_NOT_FUND_ACCOUNT("46004","提现失败,提交的提现记录中存在不能识别的收款账号信息,请重试"),
	FAIL_TO_SUBMIT_WITHDRAW_AMOUNT_IS_ZERO("46005","提现失败,提交的提现记录中存在提现金额<=0的记录,请检查"),
	FAIL_TO_SUBMIT_WITHDRAW_AMOUNT_GREATER_THAN__AVILABLE_AMOUNT("46006","提现失败,提现金额不能大于可用金额,请检查"),
	FAIL_TO_SUBMIT_WITHDRAW_ERROR_WITHDRAW_ACCOUNT_STATUS("46007","提现失败，选择的提现账户未通过系统审核"),
	FAIL_TO_SUBMIT_WITHDRAW_ERROR_STORE_STATUS("46008","提现失败，提现的账户对应的店铺未通过系统审核"),
	FAIL_TO_SUBMIT_WITHDRAW_ERROR_STORE_ACCOUNT_MAP("46009","提现失败，提现的账户对应的店铺不正确"),
	FAIL_TO_SUBMIT_WITHDRAW_ERROR_STORE_ACCOUNT_STATUS("46010","提现失败，提现的账户未通过系统审核"),
	ACCOUNT_TRANSACTION_NOT_FUND("46011","交易流水不存在"),

	EMPTY_WITHDRAW_BATCH_INFO("46012", "提现批次号对应的提现信息不存在，请检查！"),
	FAIL_TO_EDIT_WITHDRAW_EXCHANGE_RATE_BY_STATUS("46013", "该提现批次已经做支付下发处理，不能进行汇率修改"),
	FAIL_TO_EDIT_WITHDRAW_EXCHANGE_RATE_BY_EXCEPTION("46014", "修改汇率信息异常，请重试"),
	FAIL_TO_EDIT_WITHDRAW_EXCHANGE_RATE_BY_BANK_AMOUNT("46018", "修改汇率信息异常，资金入账金额和预计入账金额不匹配"),
	EMPTY_WITHDRAW_BATCH_BY_BATCH_NUM("46015", "提现批次不存在，请重新输入"),
	NO_PENDING_WITHDRAWS("46016", "当前没有需要处理的提现, 不再生成新提现批次"),
	LESS_THAN_MIN_WITHDRAW_AMOUNT("46017","提现金额小于该币种({0})最小金额({1})限制"),
	MERCHANT_PLATFORM_NOT_FOUND("46018", "平台未找到"),


	/** ----- 机构操作相关 ----- **/
	FAIL_TO_SUBMIT_AGENT("47001", "新增机构失败，请重试"),
	FAIL_TO_AUDITING_AGENT_BY_STATUS("47002", "机构审核失败，当前状态不能进行审核"),
	FAIL_TO_UPDATE_AGENT_BY_STATUS("47003", "机构编辑失败，当前状态不能进行编辑"),
	FAIL_TO_AUDITING_AGENT_BY_EXCEPTION("47003", "机构审核失败"),
	FAIL_TO_CREATE_MERCHANT_MANAGER_ERROR("470004", "商户已经添加过客户经理"),
	FAIL_TO_MODIFY_MERCHANT_MANAGER_ERROR("470005", "该商户未添加过客户经理，请添加商户经理"),
	HEAD_OFFICE_BAN_UPDATE("470006", "总部员工不能修改已存在绑定关系的商户信息"),

	AGENT_NOT_FOUND("47004", "机构未找到"),
	FAIL_TO_SUBMIT_AGENT_BY_PARENT_ID_IS_NULL("47005", "新增机构失败，父级机构不能为空"),
	FAIL_TO_SUBMIT_AGENT_BY_PARENT_NOT_FUND("47006", "新增机构失败，未能找到父级机构"),
	FAIL_TO_SUBMIT_AGENT_BY_LOGIN_USER("47007", "新增机构失败，父级机构必须为登录机构"),
	FAIL_TO_SUBMIT_AGENT_BY_LEVEL("47008", "新增机构失败，您已经是3级机构，不能增加子级机构"),
	FAIL_TO_SUBMIT_AGENT_BY_MOBILE("47009","新增机构失败，手机号码已经被使用，请联系管理员"),
	FAIL_TO_EXPORT_CHANNEL_COST_BY_USER_TYPE("47010","下载失败，你当前登录身份不能进行该报表下载"),
	FAIL_TO_LOAD_AGENT_INFO("47011","获取机构失败，只能获取子级机构信息"),
	FAIL_TO_EDIT_AGENT_INFO("47012","修改机构失败，只能修改子级机构信息"),
	ORG_DISPLAY_NAME_INVALID("47013","机构用户名为6~20位数字和字母"),
	ORG_USER_NAME_EXISTS("47014","机构自定义用户名已存在"),
	ORG_AUTO_USER_NAME_EXISTS("47015","机构自动生成用户名已存在"),

	/** ----- 对账操作相关 ----- **/
	ACCOUNT_CHECK_FILE_NOT_FUND("48000","对账文件未找到"),
	EMPTY_ACCOUNT_CHECK_FILE("48001", "没有待对账的文件信息"),
	FAIL_TO_ACCOUNT_CONFIRM_BY_STATUS("48002","当前状态不能进行资金入账确认"),
	FAIL_TO_ACCOUNT_CONFIRM_BY_ACCOUNT_INCOME_DATA_WRAP_IS_EMPTH("48012","资金入账内容不能为空"),
	FAIL_TO_ACCOUNT_CONFIRM_BY_BANK_AMOUNT_EMPTY("48003","入账总额不能为空"),
	FAIL_TO_ACCOUNT_CONFIRM_BY_BANK_SERIAL_EMPTY("48004","网银流水号不能为空"),
	EMPTY_ACCOUNT_CHECK_FILE_BY_BATCH_NUM("48005", "该批次号对账文件不存在"),
	FAIL_BATCH_PAY_BY_STATUS("48006", "当前状态不能进行下发"),
	FAIL_BATCH_PAY_BY_SYNC("48007", "当前批次下发正在处理中，请稍后"),
	NO_RECONCILATION_TIME_SETUP("48008", "没有对账方对账文件查询时间组"),
	INVALID_PARAMETER("48009", "非法的查询参数"),
	FAIL_TO_PAY("48010","下发失败，请联系管理员"),
	FAIL_TO_PAY_BY_EMPTY_TRANSACTION("48011","下发失败，不存在需要下发的记录信息"),

	ERRO_ACCOUNT_CHECK_BY_FILE_TYPE("48012","对账文件类型不支持"),
	ERRO_ACCOUNT_CHECK_BY_FILE_NAME("48013","对账文件名称定义错误"),
	ACCOUNT_CHECK_INCOME_DETAIL_NOT_FUND("48014","对账明细信息未找到"),
	ACCOUNT_CHECK_INCOME_DETAIL_AMOUNT_NOT_CHANGE("48015","调整入账金额失败，调整金额不能为空或者为0"),
	FAIL_TO_ACCOUNT_CONFIRM_BY_RECEIVABLES_Bank_FEE_AMOUNT_EMPTY("48016","收款行手续费不能为空"),
	FAIL_TO_ACCOUNT_CONFIRM_BY_RECEIVABLES_BANK_FEE_AMOUNT_LESS_THAN_ZERO("48016-1","收款行手续费不能小于零"),
	FAIL_TO_ACCOUNT_CONFIRM_BY_INTERMEDIARY_BANK_FEE_AMOUNT_EMPTY("48017","中间行手续费不能为空"),
	FAIL_TO_ACCOUNT_CONFIRM_BY_INTERMEDIARY_BANK_FEE_AMOUNT_LESS_THAN_ZERO("48017-1","中间行手续费不能小于零"),
	FAIL_TO_ACCOUNT_CONFIRM_BY_DB_ERROR("48018","资金对账失败，错误原因（DB），请联系管理员"),
	MULTIPLE_ACCOUNT_CHECK_FILE_FOUND("48019", "同一对账文件名称发现多笔对账文件记录，请进行系统数据排查！"),
	ALREADY_EXIT_ACCOUNT_CHECK_FILE("48020", "已存在的对账文件！"),
	INCOME_ACCOUNT_CHECK_WRONG_SUM_TOTAL("48024", "明细汇总额度和对账文件中总统计额度不匹配"),
	ACCOUNT_CHECK_INCOME_DETAIL_INFO_IS_EMPTY("48025","调整入账信息失败，请完善银行卡信息"),
	PAT_BATCH_NOT_FUND("48026","该下发批次信息不存在"),
	FAIL_TO_CONFIG_BATCH_RESULT("48027","设置下发明细结果失败"),
	FAIL_TO_CONFIG_BATCH_RESULT_BY_FEEDBACK("48028","设置失败，当前状态不能进行设置"),
	FAIL_TO_UPLOAD_VALID_INCOME_FILE("48029", "不合法的对账文件格式"),
	FAIL_BATCH_PAY_BY_COUNTRY_HK("48030", "下发失败，只能下发国家为CN的提现批次"),
	FAIL_BATCH_PAY_BY_COUNTRY_CN("48031", "导出失败，只能导出国家为HK的提现批次"),
	FAIL_BATCH_BALANCE_IS_NOT_ENOUGH("48032", "下发失败，账户余额不足"),
	FAIL_BATCH_RESP_INFO_FORMAT_ERROR("48033", "查询账户信息返回数据格式不正确"),
	FAIL_DELETE_ACCOUNT_CHECK_FILE_BY_STATUS("48034", "删除对账文件失败，当前状态不能进行删除"),
	FAIL_TO_EDIT_EXCHANGE_RATE_BY_STATUS("48035", "当前状态不能进行汇率修改"),
	FAIL_TO_DOWNLOAD_EXCHANGE_FILE_BY_MODEL("48036", "当前模式下不能进行结汇文件下载"),
	FAIL_TO_ACCOUNT_CONFIRM_BY_TOTAL_AMOUNT("48037","资金对账失败，错误原因（银行入账金额和预计入账金额不符）"),


	RIGHTS_DISTRIBUTE_NOT_ENOUGH("049001","权益不足，请调整权益数量"),
	PROMOTION_RULE_NAME_EXISTS("049002","营销规则名称已存在"),
	ROOT_NOT_SUPPORT_OPER("049003","管理员不支持该操作"),
	RIGHT_HAVE_ALREADY_EXISTS("049004","已为该商户分配过该权益"),
	INVALID_DISCOUNT_RATE("049005","无效的费率"),
	PROMOTION_RULE_NOT_FOUND("049006","营销规则不存在或已失效!"),

	/** ----- 第三方系统相关 -----**/
	FAIL_TO_SEND_SMS ("80001", "发送短信验证码失败"),
	FAIL_TO_GET_SMS("80002", "短信验证码错误或已过期"),
	ATTACK_TO_SEND_SMS("80003","短信已发送至您手机，若您暂未收到，请您在一分钟之后再试"),
	SYSTEM_EXCEPTION("90001", "系统异常"),


	/**  ---- Authentication related error ----. */
	AUTH_INVALID_PASSWORD_USERNAME("40000", "用户名或密码不正确！"),
	AUTH_INVALID_TOKEN_EXPIRE("40001", "token过期"),
	AUTH_INVALID_TOKEN("40002", "Invalid api token!"),
	AUTH_UNKNOWN_LOGIN_TYPE("40003", "未知的Login类型!"),
	INVALID_CUSTOM_TOKEN("40004","自定义TOKEN验证失败！"),
	USER_NOT_FOUND("40005", "未找到用户"),
	MERCHANT_NOT_FOUND("40007", "未找到商户"),

	AUTH_INVALID_LOAD_FILE("40006","非法获取图片地址");





    /** The code. */
	private String errorCode;

	/** The message. */
	private String errorMsg;

	/**
	 * Instantiates a new error detail.
	 *
	 * @param errorCode the code
	 * @param errorMsg the message
	 */
	private ErrorDetail(String errorCode, String errorMsg) {
		this.errorCode = errorCode;
		this.errorMsg = errorMsg;
	}

	/**
	 * Gets the code.
	 *
	 * @return the code
	 */
	public String getErrorCode() {
		return errorCode;
	}

	/**
	 * Gets the message.
	 *
	 * @return the message
	 */
	public String getErrorMsg() {
		return errorMsg;
	}

	/**
	 * Resolve.
	 *
	 * @param code the code
	 * @return the error detail
	 */
	public static ErrorDetail resolve(String code) {
		for (ErrorDetail item : values()) {
			if (item.getErrorCode().equalsIgnoreCase(code)) {
				return item;
			}
		}
		return null;
	}
	
	/**
	 * With parameters.
	 *
	 * @param params the parameters
	 * @return the string
	 */
	public String withParams(Object... params) {
		return MessageFormat.format(this.errorMsg, params);
	}

}